package com.sam.jifenbao;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.ListViewAutoScrollHelper;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ShopListActivity extends BaseActivity {

    private ListView shopListView;

    private static final String KEY_SHOP_NAME = "shop_name";
    private static final String KEY_SHOP_PHONE = "shop_phone";
    private static final String KEY_SHOP_ADDRESS = "shop_address";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_list);
        findView();
        initView();
    }
    @Override
    protected void findView(){
        shopListView = (ListView) findViewById(R.id.shop_list);
    }

    @Override
    protected void initView() {
        List<Map<String,String>> data = new ArrayList<>();
        for(int i = 0; i < 20; i++){
            Map<String,String> map = new HashMap<>();
            map.put(KEY_SHOP_NAME,"卡路里先生(上地店)");
            map.put(KEY_SHOP_PHONE,"010 8666666666");
            map.put(KEY_SHOP_ADDRESS,"北京市海淀区上地七街环岛路8号");
            data.add(map);
        }
        SimpleAdapter shopListAdapter = new SimpleAdapter(ShopListActivity.this,data,R.layout.shop_listview_item,
                new String[]{KEY_SHOP_NAME,KEY_SHOP_PHONE,KEY_SHOP_ADDRESS},
                new int[]{R.id.shop_name,R.id.shop_phone,R.id.shop_address});
        shopListView.setAdapter(shopListAdapter);
    }
}
